<!--
 * @Description: 页面跳转选择组件

 * @Date: 2021-08-12 11:06:37

 * @LastEditTime: 2021-09-26 19:38:10
-->

<template>
  <config-item :label="label">
    <div class="flex col-center h32">
      <div v-if="!value.id" class="f12 f-theme pointer" @click="open">
        选择跳转到的页面
      </div>

      <template v-else>
        <el-tag size="small" class="pageName">{{ pageName }}</el-tag>
        <span class="ml5 f12 f-theme pointer" @click="open">修改</span>
      </template>
    </div>
    <div v-if="['category','car','my'].indexOf(value.id)==-1">
      <JumpDialog ref="jump" :tabs='tabs' @close="close" :itemPage="value" :mallDataList="mallDataList" :textDataList="textDataList"></JumpDialog>
    </div>
  </config-item>
</template>

<script>
import schemaMixin from "@/mixin/schemaMixin";
import { mapGetters } from "vuex";

export default {
  name: "SchemaJump",
  mixins: [schemaMixin],
  provide() {
    return {
      value: this.value
    };
  },
  props: {
    value: {
      default: () => ({})
    }
  },
  data() {
    return {
      mallDataList:JSON.parse(localStorage.getItem('mallDataList'))||[],
      pageName:'',
      tabs: [
        {
          label: "微页面",
          type: "fixed",
        },
        {
          label: "自定义页面",
          type: "custom",
        },
        {
          label: "站外链接h5",
          type: "webh5",
        },
        {
          label: "类型链接",
          type: "link",
        },
        {
          label: "酒店链接",
          type: "wineshoplink",
        },
        // {
        //   label:"指定产品",
        //   type:"specifiedProduct",
        // },
        {
          label: "指定商品",
          type: "designatedGoods",
        },
        {
          label: "微信跳转",
          type: "wechatImg",
        },
        {
          label: "不跳转",
          type: undefined,
        },
        {
          label: "指定教练",
          type: "coach",
        },
        {
          label: "拨打电话",
          type: "phone",
        },
        {
          label: "地址",
          type: "address",
        },
        {
          label: "二级页跳转",
          type: "twoPageJump",
        },
        {
          label: "文本跳转",
          type: "textPageJump",
        },
      ],
      mValue: null,
      valueName: "",
      fixedPages: [
        {
          id: "/pages/index/index",
          name: "首页",
          type: "fixed"
        },
        {
          id: "/pages/index/cart",
          name: "购物车",
          type: "fixed"
        },
        {
          id: "/pages/index/user",
          name: "我的",
          type: "fixed"
        },
        {
          id: "/pages/index/category",
          name: "商品分类",
          type: "fixed"
        }
      ],
      textDataList: JSON.parse(localStorage.getItem('TextsDataList'))||[],
    };
  },
  methods: {
    close(name){
      this.pageName = name
    },
    open() {
      this.$refs.jump.open(this.value);
    },
  },

};
</script>

<style lang="scss" scoped>
.pageName{
  width: 111px;
  overflow: hidden;
}
</style>
